<%@page import="com.group.attendance.AttendaceBean"%>
<%@page import="java.util.ArrayList"%>
<%@page import="java.util.Calendar"%>
<%@page import="java.util.GregorianCalendar"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<jsp:useBean id="Atd" class="com.group.attendance.AttendaceDAO" />

<%
	GregorianCalendar nowTime = new GregorianCalendar();
	String time = String.format("%TT",nowTime);
%>
<%
	request.setCharacterEncoding("utf-8");
    
    Calendar now = Calendar.getInstance();
    int year = now.get(Calendar.YEAR);
    int month = now.get(Calendar.MONTH)+1;
    int day = now.get(Calendar.DATE);
    
    String _year = request.getParameter("year");
    String _month = request.getParameter("month");
    String _day = request.getParameter("day");
    
    if(_year != null)
        year = Integer.parseInt(_year);
    
    if(_month != null)
        month = Integer.parseInt(_month);
    
    if(_day != null)
    	day = Integer.parseInt(_day);
    
    
    now.set(year, month-1, 1);    //달
    //now.set(year, month,day-1);
    
    year = now.get(Calendar.YEAR);    //년도 변경
    month = now.get(Calendar.MONTH) +1;
    day = now.get(Calendar.DAY_OF_MONTH) ;
    
   
%>


<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">
<title>Insert title here</title>
<script type="text/javascript">
	//CDATE 시간 출력
	var tmid;

	window.onload = function() {
		setInterval(fncSetTime, 1000);
		tmid = document.getElementById('time');
	}

	function fncSetTime() {
		var today = new Date();
		tmid.innerHTML = fncLpad(today.getHours()) + ':'
				+ fncLpad(today.getMinutes()) + ':'
				+ fncLpad(today.getSeconds());
	}

	function fncLpad(num) {
		if (num < 10)
			return '0' + num;
		else
			return num;
	}
	function chk(){
		alert("출근확인");
		
		location.href = "main_proc.jsp";
	}
	function out(){
		alert("퇴근확인");
		
		location.href = "main_out.jsp";
	}
	
</script>
</head>

<body>
	<jsp:include page="../common/top.jsp"></jsp:include>
	<br>
	<br>
	<br>
	<br>
	<br>

	<a href="main.jsp?year=<%=year%>&month=<%=month%>&day<%=day-1%>">◀</a>
	<b><%=year%>年 <%=month%>月<%=day %>日</b>
	<a href="main.jsp?year=<%=year%>&month=<%=month%>&day<%=day+1%>">▶</a>
	<br>
	<a href="main.jsp?year=<%=year%>&month=<%=month -1%>">◀</a>
	<b><%=year%>年 <%=month%>月<%=day %>日</b>
	<a href="main.jsp?year=<%=year%>&month=<%=month +1%>">▶</a>
	
	<div id='time'></div>
	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
	&nbsp;&nbsp;&nbsp;


	<input type="button" align="right"  value="chk" onclick="chk()">
	
	<input type="button" align="right" value="out" onclick="out('퇴근')">
	<!-- 현재시간 출력 -->

	<br>
	<br>
	<br>
	<table width="98%" border="1" >

		<tr height="22" bgcolor="#e1dace" style='font-weight:bold;'>
			<td width="70" align="center">이름</td>			
			<td width="80" align="center">출근시간</td>
			<td width="80" align="center">퇴근시간</td>
			<td width="80" align="center">구분</td>
			<%
				ArrayList<AttendaceBean> list = Atd.getData();
				for (int i = 0; i<list.size(); i++){
					AttendaceBean bean = list.get(i);
			%>
		
		<tr>
		 	<td align="center"><%=bean.getNAME() %></td>			 		
			<td align="center"><%=bean.getCHECK_IN() %></td>
		 	<td align="center"><%=bean.getCHECK_OUT() %></td>
		  	<td align="center"><%=bean.getCHECK_DIV() %></td>		
			<%
				}				
			%>
		
	</table>	

</body>
</html>